<?php

/*
 * Victory 4$
 * 
 * Worth 1 Victory Point for every 3 Silvers in your deck (rounded down).
 * When you trash this, gain 3 silvers
 */

class Feodum extends Card implements iKingdom, iDarkAges, iVictory {

    public function __construct() {
        parent::__construct("Feodum", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Worth 1 Victory Point for every 3 Silvers in your deck (rounded down).",
            "When you trash this, gain 3 silvers");
    }

    public function trash($game, $name) {
        $s1 = $game->moveCardFromPileToPile("Silver", BoardCards, DiscardPile, $name);
        $s2 = $game->moveCardFromPileToPile("Silver", BoardCards, DiscardPile, $name);
        $s3 = $game->moveCardFromPileToPile("Silver", BoardCards, DiscardPile, $name);

        $silvers = array();
        if ($s1)
            $silvers[] = $s1;
        if ($s2)
            $silvers[] = $s2;
        if ($s3)
            $silvers[] = $s3;

        ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($silvers), "gains" . nicePrint($silvers), $name);
        $game->setTempCard($this);
        $game->cardTrashFinished($name);
    }

    public function getVictoryPoints(Game $game, $name) {
        $silvers = 0;
        $allCards = $game->getAllCards($name);
        foreach ($allCards as $card) {
            if ($card instanceof Silver) {
                $silvers+=1;
            }
        }
        return floor($silvers / 3);
    }

    public function play(Game $game, $isRealCard) {
        
    }

}

?>